#!/usr/bin/env node

const fs = require('fs');

const file = process.argv[2] ?? __filename

if (!file) {
    console.error('Usage: node 10-my-touch.js <file-to-create>');
    process.exit(1);
}

// 创建指定名称的空文件
try {
    fs.writeFileSync(file, Buffer.from(''));
  } catch (err) {
    console.error('Error: Failed to create file.', err);
  }

//ls
//./10-my-touch.js 10.txt
//ll 10.txt